/*
 * Copyright 2013 Agustina Martinez-Garcia

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package uk.ljmu.fedoraifz.main;

//import uk.ljmu.fedoraifz.restrequests.FedoraOperationsAPIM;
import org.igfay.jfig.JFigException;

import uk.ljmu.fedoraifz.restrequests.FedoraOperationsAPIM;
import uk.ljmu.fedoraifz.restrequests.FedoraOperationsAPIMImpl;
//import uk.ljmu.fedoraifz.restrequests.FedoraOperationsAPIMImpl;

public class Main {
    @SuppressWarnings("unused")
    private static String DEMO_REST_FOXML;

    static {        
	// Test FOXML object with RELS-EXT datastream
	StringBuilder sb = new StringBuilder();
	sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	sb.append("<foxml:digitalObject VERSION=\"1.1\"  PID=\"demo:1169\" ");
	sb.append("  xmlns:foxml=\"info:fedora/fedora-system:def/foxml#\" ");
	sb.append("  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ");
	sb.append("  xsi:schemaLocation=\"info:fedora/fedora-system:def/foxml# ");
	sb.append("  http://www.fedora.info/definitions/1/0/foxml1-1.xsd\">");
	sb.append("  <foxml:objectProperties>");
	sb.append("    <foxml:property NAME=\"info:fedora/fedora-system:def/model#state\" VALUE=\"A\"/>");
	sb.append("  </foxml:objectProperties>");
	sb.append("  <foxml:datastream ID=\"DC\" CONTROL_GROUP=\"X\" STATE=\"A\">");
	sb.append("    <foxml:datastreamVersion ID=\"DC1.0\" MIMETYPE=\"text/xml\" LABEL=\"DC Record for Coliseum image object\">");
	sb.append("      <foxml:xmlContent>");
	sb.append("        <oai_dc:dc xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\">");
	sb.append("          <dc:title>Coliseum in Rome</dc:title>");
	sb.append("          <dc:creator>Thornton Staples</dc:creator>");
	sb.append("          <dc:subject>Architecture, Roman</dc:subject>");
	sb.append("          <dc:description>Image of Coliseum in Rome</dc:description>");
	sb.append("          <dc:publisher>University of Virginia Library</dc:publisher>");
	sb.append("          <dc:format>image/jpeg</dc:format>");
	sb.append("          <dc:identifier>demo:1169</dc:identifier>");
	sb.append("        </oai_dc:dc>");
	sb.append("      </foxml:xmlContent>");
	sb.append("    </foxml:datastreamVersion>");
	sb.append("  </foxml:datastream>");
	sb.append("  <foxml:datastream ID=\"RELS-EXT\" CONTROL_GROUP=\"M\" STATE=\"A\">");
	sb.append("    <foxml:datastreamVersion ID=\"RELS-EXT.0\" MIMETYPE=\"text/xml\" LABEL=\"Relationships\">");
	sb.append("      <foxml:xmlContent>");
	sb.append("        <rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"" +
	"                 xmlns:rel=\"info:fedora/fedora-system:def/relations-external#\">");
	sb.append("          <rdf:Description rdf:about=\"info:fedora/demo:1169\">");
	sb.append("            <rel:hasFormalContentModel rdf:resource=\"info:fedora/demo:UVA_STD_IMAGE_1\"/>");
	sb.append("          </rdf:Description>");
	sb.append("        </rdf:RDF>");
	sb.append("      </foxml:xmlContent>");
	sb.append("    </foxml:datastreamVersion>");
	sb.append("  </foxml:datastream>");
	sb.append("  <foxml:datastream ID=\"DS1\" CONTROL_GROUP=\"X\" STATE=\"A\">");
	sb.append("    <foxml:datastreamVersion ID=\"DS1.0\" MIMETYPE=\"text/xml\" LABEL=\"DC Record for Coliseum image object\">");
	sb.append("      <foxml:xmlContent>");
	sb.append("        <foo>");
	sb.append("          <bar>baz</bar>");
	sb.append("        </foo>");
	sb.append("      </foxml:xmlContent>");
	sb.append("    </foxml:datastreamVersion>");
	sb.append("  </foxml:datastream>");
	sb.append("</foxml:digitalObject>");

	DEMO_REST_FOXML = sb.toString();
    }

    @SuppressWarnings("unused")
    private static String dsData;
    static {
	StringBuilder sb = new StringBuilder();
	sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
	sb.append("<foxml:datastream xmlns:foxml=\"info:fedora/fedora-system:def/foxml#\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd\" ID=\"RDF\" STATE=\"A\" CONTROL_GROUP=\"X\" VERSIONABLE=\"true\">");
	sb.append("<foxml:datastreamVersion ID=\"RDF1.0\" LABEL=\"Dublin Core Record for this object\" MIMETYPE=\"text/xml\" FORMAT_URI=\"http://www.openarchives.org/OAI/2.0/oai_dc/\">");
	sb.append("<foxml:xmlContent>");
	sb.append("<oai_dc:dc xmlns:oai_dc=\"http://www.openarchives.org/OAI/2.0/oai_dc/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd\">");
	sb.append("<dc:title>Root Demo Objects Collection</dc:title>");
	sb.append("<dc:identifier>demo:root</dc:identifier>");
	sb.append("</oai_dc:dc>");
	sb.append("</foxml:xmlContent>");
	sb.append("</foxml:datastreamVersion>");
	sb.append("</foxml:datastream>");

	dsData = sb.toString();
    }

    /**
     * @param args
     */
    public static void main(String[] args) {
	//FedoraOperationsAPIM fedOp = new FedoraOperationsAPIMImpl();
	FedoraOperationsAPIM fedOp4;
	try {
	    fedOp4 = new FedoraOperationsAPIMImpl();
	    System.out.println(fedOp4.getObjectXML("demo:7"));
	} catch (JFigException e) {
	    e.printStackTrace();
	}
	//System.out.println(fedOp4.getNextPID(1, "demo", "xml"));
	//System.out.println(fedOp4.validate("demo:root", "2010-09-01"));
	//System.out.println(fedOp4.getDatastreams("demo:root", "xml", ""));
	//	System.out.println(fedOp4.getDatastream("demo:root", "DC", "xml", "2010-08-11", "true"));
	//	System.out.println(fedOp4.addDatastream("demo:root", "RDF", dsData, "text/xml"));
	//System.out.println(fedOp4.createObject());
	//System.out.println(fedOp.deleteObject("demo:1169"));
	//System.out.println(fedOp4.createObject("demo:1170", "http://localhost/Foxml.xml", "text/xml", "Test create new object", "Test", "info:fedora/fedora-system:FOXML-1.1", "UTF-8", "demo", "fedoraAdmin", "A", "false"));	
    }
}
